#! /bin/bash
export LANG=en_US.UTF-8

result=
PID=
Port=
lineport=
lineport1=
function getPIDByPort() {
	Port=$1
	PID=
	if [[ "$Port" != "" ]];then
		PID=`netstat -anp|grep ":$Port"|grep "LISTEN"|awk -F " " '{print $7}'|head -n 1|sed 's/\(.*\)\/\(.*\)/\1/g'`
	fi		
}

for line in `find /iflytek/config -name "*.propertiess" |grep "config/"`
do
	if [[ "$line" != "" ]];then
		lineport=""
		lineport=`cat $line |grep -v '<!\-\-'|grep "dubbo.protocol"|sed 's/\(.*\)port="\([0-9]*\)"\(.*\)/\2/g'`
		if [[ "$lineport" != "" ]]; then
			lineport1=${lineport#*=}
			echo lineport1
			getPIDByPort $lineport1
			if [[ "$PID" != "" ]];then
				echo FLAG" "$PID":"$lineport1
			fi
		fi
	fi
done


